DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomImage3D Class / SetTransferFunction Method / SetTransferFunction(Single,Single,Color[]) Method
The pixel value to be mapped to the first element of the Colours array
The pixel value to be mapped to the last element of the Colours array
An array of Color values
Example

In This Topic
    SetTransferFunction(Single,Single,Color[]) Method
    In This Topic
    Set the transfer function (Colour Map) for use in Volume Rendering
    Syntax
    'Declaration
     
    
    Public Overloads Sub SetTransferFunction( _
       ByVal Min As System.Single, _
       ByVal Max As System.Single, _
       ByVal Colours() As System.Drawing.Color _
    ) 
    public void SetTransferFunction( 
       System.float Min,
       System.float Max,
       System.Drawing.Color[] Colours
    )

    Parameters

    Min
    The pixel value to be mapped to the first element of the Colours array
    Max
    The pixel value to be mapped to the last element of the Colours array
    Colours
    An array of Color values
    Remarks

    The alpha values are central to Volume rendering, and it is important that "transparent" pixel ranges should be to colours with an alpha value < 1.

    Pixel values less than the Min value are mapped to the first colour in the array and those greater than the Max value are mapped to the last value.

    Example
    DicomImage image = new DicomImage("your_3D_dicom_image.dcm");
    DicomVolume volume = new DicomVolume(image);
                        
    RenderMode3D renderMode = RenderMode3D.MPR;
    DicomImage3D image3D = new DicomImage3D(volume, renderMode);
           
    // Typical pixel range for 12 bit CT
    float minPixelValue = -1024;
    float maxPixelValue = 3071;
                        
    Color[] colorMap = new Color[]
    {
        Color.FromArgb(0, 0, 0, 0), // Fully transparent black (Air)
        Color.FromArgb(50, 0, 0, 255), // Slightly visible blue
        Color.FromArgb(100, 0, 255, 0), // Green (soft tissue)
        Color.FromArgb(200, 255, 0, 0), // Red (high-intensity structures)
        Color.FromArgb(255, 255, 255, 255) // Fully opaque white (Bone)
    };    
                
    image3D.SetTransferFunction(minPixelValue, maxPixelValue, colorMap);
    Viewer.Images.Add(image3D);
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also